﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SqlMiM.Common.ViewModel;
using SqlMiM.Common;
using System.Windows.Media;
using System.Collections.ObjectModel;
using MvvmFoundation.Wpf;

namespace SqlMiM.ViewModel
{
    public class PluginGroupViewModel : ObservableObject
    {

        private IPluginGroup pluginGroup;
        private ObservableCollection<PluginViewModel> plugins;

        public IPluginGroup PluginGroup
        {
            get { return pluginGroup; }
            set
            {
                pluginGroup = value;
                this.RaisePropertyChanged("PluginGroup");
            }
        }

        public PluginGroupViewModel(IPluginGroup pluginGroup)
        {
            this.pluginGroup = pluginGroup;

            this.plugins = new ObservableCollection<PluginViewModel>();
            
            if (pluginGroup != null && pluginGroup.Plugins != null)
               foreach (var plugin in pluginGroup.Plugins)
                    this.Plugins.Add(new PluginViewModel(plugin));

        }


        public String Name
        {
            get
            {
                return this.pluginGroup.Name;
            }
        }
        public String Description
        {
            get
            {
                return this.pluginGroup.Description;
            }
        }
        public ImageSource Icon
        {
            get
            {
                return this.pluginGroup.Icon;
            }
        }

        public ObservableCollection<PluginViewModel> Plugins
        {
            get
            {
                return this.plugins;
            }
            set
            {
                this.plugins = value;
                this.RaisePropertyChanged("Plugins");
            }
        }

        public int Index
        {
            get
            {
                return this.pluginGroup.Index;
            }
            set
            {
                this.pluginGroup.Index = value;
                this.RaisePropertyChanged("Index");
            }
        }


    }
}
